angular
    .module('baocloud.components.tabs',[])
    .directive('tabs', tabs)
    .controller('TabsController', TabsController);

function tabs() {
    var directive = {
        restrict: 'E',
        replace: true,
        scope: {
            datasets: '=',
            selected: '@',
            tabChange: '&'

        },
        templateUrl: function (element, attrs) {
            return attrs.templateUrl || 'tabs/tabs.html';
        },
        controller: 'TabsController',
        controllerAs: 'tabs'

    };
    return directive;
}

function TabsController($scope){
    var self = this;
    self.selected = $scope.selected || 0;
    self.onTabChange = function (code) {
        self.selected = code;
        $scope.tabChange({code:code});
    }
}